package one.to.many.bidir.un.un;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.TableGenerator;








//@Entity public class Employee {
//    ...
//    @TableGenerator(
//        name="empGen",
//        table="ID_GEN",
//        pkColumnName="GEN_KEY",
//        valueColumnName="GEN_VALUE",
//        pkColumnValue="EMP_ID",
//        allocationSize=1)
//    @Id
//    @GeneratedValue(strategy=TABLE, generator="empGen")
//    int id;
//    ...
//}
//
//Example 2:
//
//@Entity public class Address {
//    ...
//    @TableGenerator(
//        name="addressGen",
//        table="ID_GEN",
//        pkColumnName="GEN_KEY",
//        valueColumnName="GEN_VALUE",
//        pkColumnValue="ADDR_ID")
//    @Id
//    @GeneratedValue(strategy=TABLE, generator="addressGen")
//    int id;
//    ...
//}







//@Entity
public class E1 implements Serializable {

	private static final long serialVersionUID = 8194453761905431080L;

	@Id
	@GeneratedValue(strategy = GenerationType.TABLE, generator = "idgen")
	@TableGenerator(name = "idgen", allocationSize = 1)
	@Column(unique = true, nullable = false)
	private int e11;

	private String e12;
	
	@OneToMany(mappedBy = "e1", cascade = CascadeType.PERSIST)
	private Set<E2> e2s;

	public E1(String e12) {
		this.e12 = e12;
	}
	
	public E1(String e12, Set<E2> e2s) {
		this.e12 = e12;
		this.e2s = e2s;
	}

	public int getE11() {
		return e11;
	}

	public void setE11(int e11) {
		this.e11 = e11;
	}

	public String getE12() {
		return e12;
	}

	public void setE12(String e12) {
		this.e12 = e12;
	}
	
	public Set<E2> getE2s() {
		return e2s;
	}

	public void setE2s(Set<E2> e2s) {
		this.e2s = e2s;
	}
}
